package com.nanyang.tms.manager.waybill.handler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.nanyang.common.core.flow.context.TransHandlerContext;
import com.nanyang.common.core.flow.handler.AbstractTransHandler;
import com.nanyang.tms.common.util.TmsExceptionUtil;
import com.nanyang.tms.dao.forecast.ForecastDao;
import com.nanyang.tms.domain.forecast.ForecastDO;
import com.nanyang.tms.domain.forecast.context.CalculateWeightContext;
import com.nanyang.tms.domain.waybill.context.SaveWaybillReceiptContext;
import com.nanyang.tms.domain.waybill.context.UpdateForecastContext;
@Component
public class UpdateForecastHandler extends AbstractTransHandler {
	@Autowired
	private ForecastDao forecastDao;
	@Override
	public boolean isAsync() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean handle(TransHandlerContext context) {
		UpdateForecastContext updateForecastContext = (UpdateForecastContext) context
				.getInnerContext(UpdateForecastContext.class); 
		try {
			ForecastDO forecastDO=new ForecastDO();
			forecastDO.setForecastCode(updateForecastContext.getForecastCode());
			forecastDO.setState(updateForecastContext.getState());
			forecastDao.update(forecastDO);
		} catch (Exception e) {
			throw TmsExceptionUtil.wrapException(e);
		}
		return true;
	}

}
